package com.asdan.seededu.web.controller;

import java.util.List;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.asdan.seededu.entity.security.User;
import com.asdan.seededu.service.UserService;
import com.asdan.seededu.service.impl.UserServiceImpl;
import com.demo2do.core.utils.JsonUtils;
import com.demo2do.core.web.interceptor.MenuSetting;

@Controller
@MenuSetting("menu-user")
@RequestMapping("users")

public class UserController {
	/**
	 * Display user page
	 * 
	 * @return
	 */
	
	@RequestMapping("")
	public String users() {
		return "users";
	}
	@RequestMapping("/order")
	public String order() {
		return "order";
	}
	@RequestMapping("/teacher")
	public String teacher(String t) {
		System.out.println(t);
		return "teacher";
	}
	
	@RequestMapping("/detail")
	public String userdetail() {
		return "userdetail";
	}

	@RequestMapping("/managerdetail")
	public String managerdetail() {
		return "managerdetail";
	}
	
	@RequestMapping("/reviseusers")
	public String Reviseusers() {
		return "reviseusers";
	}	
	
	@RequestMapping("/manager")
	public String manager() {
		return "manager";
	}

	@RequestMapping("/personinformation")
	public String personinformation() {
		return "personinformation";
	}
	
	@RequestMapping(value="/findUser",method=RequestMethod.POST,produces="test/html;charset=UTF-8")
	@ResponseBody
	public String findUser(String searchName,Model model){
		System.out.println(searchName);
		UserService us = new UserServiceImpl();
		List<User> list =  us.findUser(searchName) ;
		System.out.println(JsonUtils.toJsonString(list));
		return JsonUtils.toJsonString(list) ;
	}	

}

